<%@ page language="java"
         import="com.zhuozhengsoft.pageoffice.BorderStyleType,com.zhuozhengsoft.pageoffice.OpenModeType,com.zhuozhengsoft.pageoffice.PageOfficeCtrl"
         pageEncoding="utf-8" %>
<%@ page import="com.zhuozhengsoft.pageoffice.ThemeType" %>
<%@ page import="com.zhuozhengsoft.pageoffice.wordwriter.WordDocument" %>
<%
    PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);

    WordDocument doc = new WordDocument();
    doc.getTemplate().defineDataRegion("PO_Guarantor", "[担保人]");
    doc.getTemplate().defineDataRegion("PO_SupplierAddress", "[供货单位地址]");
    doc.getTemplate().defineDataRegion("PO_BuyerAddress", "[购货单位地址]");
    doc.getTemplate().defineDataRegion("PO_No", "[合同编号]");
    doc.getTemplate().defineDataRegion("PO_GuarantorPhone", "[担保人手机]");
    doc.getTemplate().defineDataRegion("PO_ProductName", "[产品名称]");
    doc.getTemplate().defineDataRegion("PO_Buyer", "[购货单位]");
    doc.getTemplate().defineDataRegion("PO_Supplier", "[供货单位]");

    poCtrl.setWriter(doc); // 必须。

    poCtrl.setSaveFilePage("SaveFile.jsp");

    poCtrl.webOpen("doc/test.docx", OpenModeType.docNormalEdit, "zhangsan");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title></title>
    <script type="text/javascript">
        //控件中的一些常用方法都在这里调用，比如保存，打印等等
        function Save() {
            pageofficectrl.WebSave();
        }

        function ShowDefineDataRegions() {
            var drDefinedJson = pageofficectrl.word.DataRegionsDefinedAsJson;
            // alert(drDefinedJson);
            pageofficectrl.ShowHtmlModelessDialog("DataRegionDlg.htm", drDefinedJson, "left=300px;top=390px;width=700px;height=410px;frame:no;");
        }

        function OnPageOfficeCtrlInit() {
            pageofficectrl.AddCustomToolButton("保存", "Save", 1);
            pageofficectrl.AddCustomToolButton("定义数据区域", "ShowDefineDataRegions", 10);
        }
    </script>
</head>
<body>
<form action="">
    <div style="width: 1000px; height: 800px;">
        <%=poCtrl.getHtmlCode()%>
    </div>
</form>
</body>
</html>
